package com.lagou.decimal;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class DecimalReducer extends Reducer<DecimalBean, NullWritable, LongWritable, DecimalBean> {

    Long sum = 0l;

    @Override
    protected void reduce(DecimalBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable v : values) {
            sum = sum + 1;
            context.write(new LongWritable(sum), key);
        }
    }
}
